integer DV_HS = 1437;
string ANIM = "express_open_mouth";
string gsCardName = "Owner"; //CardName
list glCardRows;	//rows readed
key gkQuery;		//Filereader
integer giLine = 0;	//Line
integer gOwnerAdd =1438;
integer playTrigger=0;
default {
    state_entry() 
    {
       	glCardRows=[];
		giLine=0;
		gkQuery = llGetNotecardLine(gsCardName,giLine);
    }
    
    link_message(integer sender, integer num, string str, key id)
  	{
		if(num == DV_HS)
		{
	  		if(str =="playAnimation")
	  		{
	  			playTrigger=1;
	  		}
	  		else if(str =="stopAnimation")
	  		{
		  		playTrigger=0;
	  		}
		}
  	}
  	
  	timer()
	{
		if(playTrigger==1)
		{
			llStartAnimation(ANIM);
		}
	}
	
	attach(key attached) 
      {
        if (attached != NULL_KEY) {
            llRequestPermissions(attached, PERMISSION_TRIGGER_ANIMATION);
        } else {
            llSetTimerEvent(0.1);
        }
    }

    run_time_permissions(integer perms) 
    {
        if(perms & (PERMISSION_TRIGGER_ANIMATION)) {
            llSetTimerEvent(0.1);
        }
    }
	dataserver(key _query_id, string _data) 
    {
        if (_query_id == gkQuery) 
        {
            if (_data == EOF) 
            {
            }
            else 
            {
            	llMessageLinked(LINK_THIS, gOwnerAdd, _data, NULL_KEY);
                ++giLine;
                gkQuery = llGetNotecardLine(gsCardName, giLine);
            }
        }
    }
  	
}
